home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / ISSUE05 / CLINIC / DRAGDRPU.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-10-08  |  1.7 KB  |  67 lines

  1. unit Dragdrpu;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, StdCtrls, ExtCtrls, Grids, FileCtrl, DBGrids, DB,
  8.   DBTables;
  9.  
  10. type
  11.   TForm1 = class(TForm)
  12.     StringGrid1: TStringGrid;
  13.     SourceControl: TFileListBox;
  14.     DirectoryListBox1: TDirectoryListBox;
  15.     DriveComboBox1: TDriveComboBox;
  16.     DataSource1: TDataSource;
  17.     Table1: TTable;
  18.     DBGrid1: TDBGrid;
  19.     procedure GridDragOver(Sender, Source: TObject; X, Y: Integer;
  20.       State: TDragState; var Accept: Boolean);
  21.     procedure StringGridDragDrop(Sender, Source: TObject; X, Y: Integer);
  22.     procedure DBGridDragDrop(Sender, Source: TObject; X, Y: Integer);
  23.   private
  24.     { Private declarations }
  25.   public
  26.     { Public declarations }
  27.   end;
  28.  
  29. var
  30.   Form1: TForm1;
  31.  
  32. implementation
  33.  
  34. {$R *.DFM}
  35.  
  36. procedure TForm1.GridDragOver(Sender, Source: TObject; X,
  37.   Y: Integer; State: TDragState; var Accept: Boolean);
  38. begin
  39.   Accept := Source = SourceControl;
  40. end;
  41.  
  42. procedure TForm1.StringGridDragDrop(Sender, Source: TObject; X,
  43.   Y: Integer);
  44. begin
  45.   if Source <> SourceControl then Exit;
  46.   with Sender as TStringGrid do
  47.   begin
  48.     Perform(wm_LButtonDown, 0, MakeLong(X, Y));
  49.     Perform(wm_LButtonUp,   0, MakeLong(X, Y));
  50.     Cells[Selection.Left, Selection.Top] := SourceControl.FileName;
  51.   end;
  52. end;
  53.  
  54. procedure TForm1.DBGridDragDrop(Sender, Source: TObject; X, Y: Integer);
  55. begin
  56.   if Source <> SourceControl then Exit;
  57.   with Sender as TDBGrid do
  58.   begin
  59.     Perform(wm_LButtonDown, 0, MakeLong(X, Y));
  60.     Perform(wm_LButtonUp,   0, MakeLong(X, Y));
  61.     SelectedField.DataSet.Edit;
  62.     SelectedField.AsString := SourceControl.FileName;
  63.   end;
  64. end;
  65.  
  66. end.
  67.